// src/router/index.ts
import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/",
      component: () => import("@/views/home/index.vue"),
      meta: { requiresAuth: false },
    },
    {
      path: "/about",
      component: () => import("@/views/about/index.vue"),
      meta: { requiresAuth: false },
    },
    {
      path: "/users",
      component: () => import("@/views/users/index.vue"),
      meta: { requiresAuth: false },
    },
  ],
});

// 路由守卫示例
router.beforeEach((to) => {
  const isAuthenticated = localStorage.getItem("token");
  if (to.meta.requiresAuth && !isAuthenticated) {
    return "/login";
  }
});

export default router;
